package com.meituan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("static")
public class ImagesController {



    @Autowired
    private ResourceLoader resourceLoader;

    @RequestMapping("goodsImg")
    public ResponseEntity show(String filename) {
        String path = "G:\\meituanUpload\\goodsImg";
        try {
            return ResponseEntity.ok(resourceLoader.getResource("file:" + path + "/" + filename));
        } catch (Exception e) {
            return ResponseEntity.notFound().build();
        }
    }

    @RequestMapping("shopImg")
    public ResponseEntity show1(String filename) {
        String path = "G:\\meituanUpload\\shopImg";
        try {
            return ResponseEntity.ok(resourceLoader.getResource("file:" + path + "/" + filename));
        } catch (Exception e) {
            return ResponseEntity.notFound().build();
        }
    }
}
